﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPageAdmin.master" AutoEventWireup="true" CodeFile="List_image.aspx.cs" Inherits="Admin_List_image" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style8
        {
            width: 381px;
            text-align: center;
        }
        .style9
        {
            width: 15px;
        }
        .style10
        {
            text-align: right;
        }
        .style11
        {
            color: #66CCFF;
            font-weight: bold;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="style7">
        <tr>
            <td colspan="3" style="text-align: center">
                <asp:Label ID="Label2" runat="server" 
                    style="color: #CC9900; font-size: xx-large; font-weight: 700" Text="Pictures"></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="style8">
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center">
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                    CellPadding="4" DataKeyNames="pictureId" DataSourceID="SqlDataSource1" 
                    ForeColor="#333333" GridLines="None" 
                    onselectedindexchanged="GridView1_SelectedIndexChanged1">
                    <RowStyle BackColor="#EFF3FB" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="pictureId" HeaderText="Picture Id" 
                            InsertVisible="False" ReadOnly="True" SortExpression="pictureId" />
                        <asp:BoundField DataField="albumId" HeaderText="Album ID" 
                            SortExpression="albumId" />
                        <asp:BoundField DataField="caption" HeaderText="Caption" 
                            SortExpression="caption" />
                        <asp:BoundField DataField="filePath" HeaderText="File path" 
                            SortExpression="filePath" />
                        <asp:BoundField DataField="uploadedDate" HeaderText="Uploaded Date" 
                            SortExpression="uploadedDate" />
                        <asp:BoundField DataField="uploadedUserId" HeaderText="Uploaded UserId" 
                            SortExpression="uploadedUserId" />
                    </Columns>
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                    DeleteCommand="DELETE FROM [tblPicture] WHERE [pictureId] = @pictureId" 
                    InsertCommand="INSERT INTO [tblPicture] ([albumId], [caption], [filePath], [uploadedDate], [uploadedUserId]) VALUES (@albumId, @caption, @filePath, @uploadedDate, @uploadedUserId)" 
                    SelectCommand="SELECT * FROM [tblPicture]" 
                    UpdateCommand="UPDATE [tblPicture] SET [albumId] = @albumId, [caption] = @caption, [filePath] = @filePath, [uploadedDate] = @uploadedDate, [uploadedUserId] = @uploadedUserId WHERE [pictureId] = @pictureId">
                    <DeleteParameters>
                        <asp:ControlParameter ControlID="txtPicID" Name="pictureId" PropertyName="Text" 
                            Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:ControlParameter ControlID="ddlAlbumID" Name="albumId" 
                            PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="txtCaption" Name="caption" PropertyName="Text" 
                            Type="String" />
                        <asp:ControlParameter ControlID="FileUpload" Name="filePath" 
                            PropertyName="FileName" Type="String" />
                        <asp:ControlParameter ControlID="Calendar" Name="uploadedDate" 
                            PropertyName="SelectedDate" Type="DateTime" />
                        <asp:ControlParameter ControlID="ddlUpID" Name="uploadedUserId" 
                            PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="txtPicID" Name="pictureId" PropertyName="Text" 
                            Type="Int32" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="albumId" Type="Int32" />
                        <asp:Parameter Name="caption" Type="String" />
                        <asp:Parameter Name="filePath" Type="String" />
                        <asp:Parameter Name="uploadedDate" Type="DateTime" />
                        <asp:Parameter Name="uploadedUserId" Type="Int32" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style8">
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center">
                <asp:Button ID="Button1" runat="server" Text="Add" onclick="Button1_Click" />
&nbsp;
                <asp:Button ID="Button2" runat="server" Text="Edit" onclick="Button2_Click" />
&nbsp;
                <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Delete" />
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center">
                <asp:Label ID="Label1" runat="server" 
                    style="font-size: xx-large; font-weight: 700; color: #CC9900" Text="Edit" 
                    Visible="False"></asp:Label>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center">
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style10">
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:TextBox ID="txtPicID" runat="server" Visible="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label3" runat="server" Text="Album ID" Visible="False" 
                    CssClass="style11"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:DropDownList ID="ddlAlbumID" runat="server" 
                    DataSourceID="SqlDataSource1" DataTextField="albumId" 
                    DataValueField="albumId" Visible="False">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label4" runat="server" Text="Caption" Visible="False" 
                    CssClass="style11"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:TextBox ID="txtCaption" runat="server" Visible="False"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label5" runat="server" Text="File path" Visible="False" 
                    CssClass="style11"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:FileUpload ID="FileUpload" runat="server" Visible="False" />
            </td>
        </tr>
        <tr>
            <td class="style10" valign="top">
                <asp:Label ID="Label6" runat="server" Text="Uploaded date" Visible="False" 
                    CssClass="style11"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:Calendar ID="Calendar" runat="server" Visible="False"></asp:Calendar>
            </td>
        </tr>
        <tr>
            <td class="style10">
                <asp:Label ID="Label7" runat="server" Text="Uploaded ID" Visible="False" 
                    CssClass="style11"></asp:Label>
            </td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:DropDownList ID="ddlUpID" runat="server" Visible="False">
                    <asp:ListItem></asp:ListItem>
                    <asp:ListItem Value="1">Administartor</asp:ListItem>
                    <asp:ListItem Value="2">Staff</asp:ListItem>
                    <asp:ListItem Value="4">Upload</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="style10">
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style10">
                &nbsp;</td>
            <td class="style9">
                &nbsp;</td>
            <td>
                <asp:Button ID="Button4" runat="server" Text="Edit" Visible="False" 
                    onclick="Button4_Click" />
            </td>
        </tr>
    </table>
</asp:Content>

